import httpUtils from "@/core/utils/http.utils";
import aesUtils from "@/core/utils/aes.utils";
// service path
const urls = {
    'getSysLogPage': `/api/log/sysLog/page`,
    'getSysLogById': `/api/log/sysLog/`,
    'saveSysLog': `/api/log/sysLog`,
    'updateSysLogById': `/api/log/sysLog`,
    'deleteSysLogById': `/api/log/sysLog/`,
    'getLogType': `/api/log/sysLog/getLogType`,
    'exportLogExcel': `/api/log/sysLog/exportLogExcel`,
    'importLogExcel': `/api/log/sysLog/importLogExcel`,
    'getLogConfig': `/api/log/sysLog/getLogConfig`,
};
// service methods
const sysLogApi = {
    getSysLogPage (param) {
        return httpUtils.getEncrypt(urls.getSysLogPage, param);
    },
    getSysLogById(id) {
        return httpUtils.get(urls.getSysLogById + id, {});
    },
    saveSysLog(param) {
        return httpUtils.postRequest(urls.saveSysLog, param);
    },
    updateSysLogById(params) {
        return httpUtils.put(urls.updateSysLogById, params);
    },
    deleteSysLog(ids) {
        return httpUtils.delete(urls.deleteSysLogById + ids);
    },
    getLogType (param) {
      return httpUtils.get(urls.getLogType, param);
    },
    // 导出日志
    exportLogExcel(param, fileName) {
        // return httpUtils.postRequest(urls.exportLogExcel, param);
        param.logZipPass = aesUtils.encode(param.logZipPass);
        return httpUtils.downloadUrlMode(urls.exportLogExcel, "post",fileName,param,"zip");
    },
    // 导入日志
    importLogExcel(params){
        let  zipPass = aesUtils.encode(params.get("zipPass"));
        params.delete("zipPass");
        params.append('zipPass', zipPass);
        return httpUtils.uploadFile(urls.importLogExcel, params)
    },
    // 查看日志配置
    getLogConfig () {
        return httpUtils.getEncrypt(urls.getLogConfig);
    },
};

export default sysLogApi;
